package com.wnhoo.smartfishtank.contants.adapter;

import android.content.Context;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;


/**
 * Created by MacBookAir on 15/4/13
 */
public class AdapterDrawable extends BaseAdapter {

    // 填充数据的list
    public List<Integer> list;


    // 上下文
    private Context context;
    // 用来导入布局
    private LayoutInflater inflater = null;



    public AdapterDrawable(List<Integer> list, Context context) {
        this.context = context;
        this.list = list;
        inflater = LayoutInflater.from(context);
    }

    public void setTypeface(Typeface typeface) {

    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }


    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ImageView imageView = new ImageView(context);
        imageView.setImageResource(list.get(position));

//        ViewHolder holder = null;
//        if (convertView == null) {
//            holder = new ViewHolder();
//            convertView = inflater.inflate(R.layout.listview_item_scan, null);
//            holder.bluetooth_scan_dataplug = convertView.findViewById(R.id.bluetooth_scan_dataplug);
////            holder.list_checked = (CheckBox) convertView.findViewById(R.id.checkbox_online);
//            holder.list_name = (TextView) convertView.findViewById(R.id.list_name);
////            holder.list_desc = (TextView) convertView.findViewById(R.id.list_desc);
//            if (tf != null) {
//                holder.list_name.setTypeface(tf);
//            }
//            convertView.setTag(holder);
//        } else {
//            holder = (ViewHolder) convertView.getTag();
//        }
//        String strName = list.get(position).getDes();
//        holder.list_name.setText(strName);
//        holder.bluetooth_scan_dataplug.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                onItemTimingListener.ItemOnclick(position, v);
//            }
//        });
        return imageView;
    }

    public final class ViewHolder {
        TextView list_name;
        View  bluetooth_scan_dataplug;
//        TextView list_desc;
//        CheckBox list_checked;
    }
    private OnItemTimingListener onItemTimingListener;

    public void setOnItemTimingListener(OnItemTimingListener l) {
        onItemTimingListener = l;
    }

    public interface OnItemTimingListener {
        boolean ItemOnclick(int position, View view);
    }
}
